package com.njwb.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

@RestController
public class FileController {
    @PostMapping("page/upload")
    public String upload(@RequestParam("fileItem") MultipartFile fileItem){
        File dest = new File("E:/upload/"+fileItem.getOriginalFilename());
        //文件上传
        try {
            fileItem.transferTo(dest);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "upload success ~";
    }
}
